import request from "@/utils/request";

//再提交表单时需要制定头部信息
const headers = {
        'Content-type': 'application/x-www-form-urlencoded'
    }
    //请求头添加 Authrization:Basic client_id:client_secret

const auth = {
    username: 'mxg-blog-admin',
    password: "123456"
}
export default {
    login(data) {
        return request({
            headers,
            auth: auth, //auth 会自动转换为自定义请求头Authrization:Basic client_id:client_secret
            url: `/auth/login`,
            method: 'post',
            params: data //提交表单要用到params
        })
    },
    //查询用户名是否已被注册
    getUserByUsername(username) {
        return request({
            url: `/system/api/user/username/${username}`,
            method: "get"
        })
    },
    register(data) {
        return request({
            url: `/system/api/user/register`,
            method: "post",
            data
        })
    },
    getXieyi(data) {
        return request({
            url: `${window.location.href}/xieyi.html`,
            method: "get",
            //这里访问的时public/xieyi
        })
    },
}